﻿<%@ Page UICulture="zh-CN" Title="" Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeBehind="AdmParcelSplit.aspx.cs" Inherits="FastShip88.Admin.AdmParcelSplit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Content" runat="server">

		<div id="content_one_col">
		   
            <asp:Label ID="Label1" runat="server" Text="下面列出所有需要拆分的包裹：" CssClass="gv_prompt"></asp:Label>&nbsp;
            <br /><br />
            <div id="div_results" runat="server" visible="false" >
                <asp:GridView ID="gvResults" runat="server" AutoGenerateColumns="False" 
                    DataKeyNames="Id" DataSourceID="LinqDataSource1" Width="840px"  
                    EmptyDataText="没有数据！" 
                    onselectedindexchanged="gvResults_SelectedIndexChanged" CellPadding="5" 
                    AllowPaging="True" PageSize="5" 
                    onpageindexchanging="gvResults_PageIndexChanging"  >
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:BoundField DataField="UserName" HeaderText="用户名">
                        <ItemStyle Width="80px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="ParcelNo" HeaderText="运单号" ReadOnly="True" 
                            SortExpression="ParcelNo">
                        <ItemStyle Width="160px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="ShopName" HeaderText="商家" ReadOnly="True">
                        <ItemStyle Width="120px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Description" HeaderText="描述" ReadOnly="True" 
                            SortExpression="Description">
                        <ItemStyle Width="240px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Weight" HeaderText="重量" ReadOnly="True" 
                            SortExpression="Weight" >
                        <ItemStyle Width="80px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="ArriveDate" HeaderText="到达日期" ReadOnly="True" 
                            SortExpression="ArriveDate" DataFormatString="{0:d}" Visible="False">
                        <ItemStyle Width="100px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" 
                            SortExpression="Id" Visible="False" />
                    </Columns>
                    <SelectedRowStyle BackColor="#669999"  />
                    <HeaderStyle BackColor="#999999" ForeColor="White" />
                </asp:GridView>
                <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
                    ContextTypeName="FastShip88.DBAccess.UsersDataContext" 
                    Select="new (ParcelNo, Description, ShopInfo, Weight, ArriveDate, Id, UserId, ShopId)" 
                    TableName="ParcelInfos">
                </asp:LinqDataSource>
                <hr />
            </div>
            
            
            <div id="div_sub" runat="server" visible="false" >
            <asp:Label ID="Label2" runat="server" Text="下面列出选中包裹的拆分子包裹："   CssClass="gv_prompt"></asp:Label>&nbsp;<br /><br />
                <asp:GridView ID="gvSub" runat="server" AutoGenerateColumns="False"  EmptyDataText="目前还没有子包裹。" 
                    Width="840px" DataKeyNames="Id" DataSourceID="LinqDataSource2" 
                    onselectedindexchanged="gvSub_SelectedIndexChanged" PageSize="5">
                    <Columns>
                        <asp:CommandField ShowSelectButton="True">
                        <ItemStyle Width="60px" />
                        </asp:CommandField>
                        <asp:BoundField DataField="id" HeaderText="系统编号">
                        <ItemStyle Width="60px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Description" HeaderText="描述">
                        <ItemStyle Width="420px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Weight" HeaderText="重量">
                        <ItemStyle Width="60px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="CreateDate" HeaderText="拆分日期" 
                            DataFormatString="{0:d}">
                        <ItemStyle Width="80px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="FinishDate" HeaderText="完成日期" 
                            DataFormatString="{0:d}">
                        <ItemStyle Width="80px" />
                        </asp:BoundField>
                        <asp:CheckBoxField DataField="IsCancel" HeaderText="是否取消" ReadOnly="True">
                        <ItemStyle Width="60px" />
                        </asp:CheckBoxField>
                    </Columns>
                <SelectedRowStyle BackColor="#669999"  />
                <HeaderStyle BackColor="#999999" ForeColor="White" />
                </asp:GridView>
            
                <asp:LinqDataSource ID="LinqDataSource2" runat="server" 
                    ContextTypeName="FastShip88.DBAccess.UsersDataContext" 
                    TableName="SubParcels" Where="FromId == @FromId &amp;&amp; ToId == null " 
                    EnableDelete="True">
                    <WhereParameters>
                        <asp:ControlParameter ControlID="gvResults" Name="FromId" 
                            PropertyName="SelectedValue" Type="Int32" />
                        <%--<asp:Parameter DefaultValue="null" Name="ToId" Type="Int32" />--%>
                    </WhereParameters>
                </asp:LinqDataSource>
                <asp:Button ID="btnSplitAdd" runat="server" Text="添加子包裹" 
                    onclick="btnSplitAdd_Click" /> 

                <hr />
            </div>
            
            
            <div id="div_selected" runat="server" visible="false" >
                
             <asp:Label ID="lblSplit" runat="server" Text="为选中子包裹执行拆分操作："  CssClass="gv_prompt" ></asp:Label>&nbsp;<br /><br />          
                <asp:FormView ID="fvSelected" runat="server" DataKeyNames="Id" 
                    DataSourceID="SqlDataSource1" DefaultMode="Edit" Width="707px" 
                    onprerender="fvSelected_PreRender" onitemcommand="fvSelected_ItemCommand">
                    <EditItemTemplate>
                        
       <table style="width: 750px;" cellpadding="5">
            <tr>
                <td style="height: 18px; width: 100px">
                    &nbsp;子包裹编号：
                </td>
                <td style="height: 18px; width: 200px">
                    &nbsp;<asp:Label ID="txtParcelNo" runat="server" Text='<%# Bind("Id") %>' ></asp:Label>
                </td>
                <td style="height: 18px; width: 340px">
                     <asp:Label ID="lblId" runat="server" Text='<%# Eval("Id") %>' Visible="false" />  
                     <asp:CheckBox runat="server" ID = "chkIsCancel" Checked = '<%# Bind("IsCancel") %>'   Visible= "false" />
                </td>
            </tr>
        
           <tr>
                <td>
                    &nbsp;描述：
                </td>
                <td colspan=2 >
                    &nbsp;<asp:TextBox ID="txtDescription" runat="server" Width="500px" Height="36px" Text='<%# Bind("Description") %>' ></asp:TextBox>
                </td>
                
            </tr>
            
             <tr>
                <td>
                    &nbsp;重量：
                </td>
                <td>
                    &nbsp;<asp:TextBox ID="txtWeight" runat="server" Text='<%# Bind("Weight") %>'></asp:TextBox><font color="#ff0000">*</font>
                </td>
                <td>
                    &nbsp;单位为磅（pound）。<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                        ErrorMessage="请输入重量" ControlToValidate = "txtWeight"  ></asp:RequiredFieldValidator>
                </td>
            </tr>
               

           <tr>
            <td>
                &nbsp;体积：
            </td>
            <td>
                &nbsp;长<asp:TextBox ID="txtLength" runat="server" Width="40px" Text='<%# Bind("Length") %>'></asp:TextBox>
                  &nbsp;宽<asp:TextBox ID="txtWidth" runat="server" Width="40px" Text='<%# Bind("Width") %>'></asp:TextBox>
                &nbsp;高<asp:TextBox ID="txtHeight" runat="server" Width="40px" Text='<%# Bind("Height") %>' ></asp:TextBox>
              
            </td>
            <td>
                &nbsp;单位为英寸（inch）。
            </td>
        </tr>
        
         <tr>
            <td>
                &nbsp;创建时间：
            </td>
            <td>
                &nbsp;<asp:Label ID="lblCreateDate" runat="server" Text='<%# Bind("CreateDate") %>'></asp:Label>
            </td>
            <td>
                &nbsp;
            </td>
        </tr> 
        
          <tr>
            <td>
                &nbsp;完成时间：
            </td>
            <td>
                &nbsp;<asp:Label ID="lblFinishDate" runat="server" Text='<%# Bind("FinishDate") %>'></asp:Label>
            </td>
            <td>
                &nbsp;
            </td>
        </tr> 
      
        <tr>
            <td>
                &nbsp;系统备注：
            </td>
            <td colspan=2>
                &nbsp;<asp:TextBox ID="txtMemo" runat="server" Height="36px" Width="500px" Text='<%# Bind("Memo") %>'></asp:TextBox>
            </td>
            
        </tr>
              </tr>
                     <tr>
            <td>
                &nbsp;
            </td>
            <td colspan=2>
                &nbsp;
            </td>
            
        </tr>
    </table>
                        
                        <asp:Button ID="btnSplitComplete" runat="server" Text="单个分拆完成" CommandName="Update"  CommandArgument="SingleComplete" /> 
                        <asp:Button ID="Button1" runat="server" Text="全部分拆完成" CommandName="Update"  CommandArgument="AllComplete" /> 
                         <asp:Button ID="btnSplitCancel" runat="server" Text="单个分拆失败" CommandName="Update"  CommandArgument="SplitCancel" /> 
                         
                <asp:Button ID="btnUpdate" runat="server" Text="保存" CommandName="Update" /> &nbsp;
                <asp:Button ID="btnCancel" runat="server" Text="取消" CommandName="Cancel"  Visible ="false"  />


                    </EditItemTemplate>

        
                </asp:FormView>
                
                              <asp:Label ID="lblError" runat="server" Text="出现错误" Font-Bold="True" 
              Font-Size="Medium" ForeColor="#CC0000" Height="30px" Visible="False" 
              Width="500px"></asp:Label>
                
            <asp:Label ID="lblSuccess" runat="server" Text="操作已成功" Font-Bold="True" 
              Font-Size="Medium" ForeColor= "Green" Height="30px" Visible="False" 
              Width="500px"></asp:Label>
              
   <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:FastShip88ConnectionString %>" 
                    DeleteCommand="DELETE FROM [SubParcels] WHERE [Id] = @Id" 
                    InsertCommand="INSERT INTO [SubParcels] ([FromId], [ToId], [CreateDate], [IsCancel], [Description], [Weight], [Length], [Width], [Height], [FinishDate], [CombineDate], [Memo], [FinishUserId], [CombineUserId]) VALUES (@FromId, @ToId, @CreateDate, @IsCancel, @Description, @Weight, @Length, @Width, @Height, @FinishDate, @CombineDate, @Memo, @FinishUserId, @CombineUserId)" 
                    SelectCommand="SELECT * FROM [SubParcels] WHERE ([Id] = @Id)" 
                    
                    
                    UpdateCommand="UPDATE [SubParcels] SET  [ToId] = @ToId,  [IsCancel] = @IsCancel, [Description] = @Description, [Weight] = @Weight, [Length] = @Length, [Width] = @Width, [Height] = @Height, [FinishDate] = @FinishDate, [CombineDate] = @CombineDate, [Memo] = @Memo, [FinishUserId] = @FinishUserId, [CombineUserId] = @CombineUserId WHERE [Id] = @Id" 
                    onupdated="SqlDataSource1_Updated" onupdating="SqlDataSource1_Updating" 
                    >
       <SelectParameters>
           <asp:ControlParameter ControlID="gvSub" Name="Id" 
               PropertyName="SelectedValue" Type="Int32" />
       </SelectParameters>
       <DeleteParameters>
           <asp:Parameter Name="Id" Type="Int32" />
       </DeleteParameters>
       <UpdateParameters>
           <asp:Parameter Name="FromId" Type="Int32" />
           <asp:Parameter Name="ToId" Type="Int32" />
           <asp:Parameter Name="CreateDate" Type="DateTime" />
           <asp:Parameter Name="IsCancel" Type="Boolean" />
           <asp:Parameter Name="Description" Type="String" />
           <asp:Parameter Name="Weight" Type="Double" />
           <asp:Parameter Name="Length" Type="Int32" />
           <asp:Parameter Name="Width" Type="Int32" />
           <asp:Parameter Name="Height" Type="Int32" />
           <asp:Parameter Name="FinishDate" Type="DateTime" />
           <asp:Parameter Name="CombineDate" Type="DateTime" />
           <asp:Parameter Name="Memo" Type="String" />
           <asp:Parameter Name="FinishUserId" Type="Int32" />
           <asp:Parameter Name="CombineUserId" Type="Int32" />
           <asp:Parameter Name="Id" Type="Int32" />
       </UpdateParameters>
       <InsertParameters>
           <asp:Parameter Name="FromId" Type="Int32"  />
           <asp:Parameter Name="ToId" Type="Int32" />
           <asp:Parameter Name="CreateDate" Type="DateTime" />
           <asp:Parameter Name="IsCancel" Type="Boolean" />
           <asp:Parameter Name="Description" Type="String" />
           <asp:Parameter Name="Weight" Type="Double" />
           <asp:Parameter Name="Length" Type="Int32" />
           <asp:Parameter Name="Width" Type="Int32" />
           <asp:Parameter Name="Height" Type="Int32" />
           <asp:Parameter Name="FinishDate" Type="DateTime" />
           <asp:Parameter Name="CombineDate" Type="DateTime" />
           <asp:Parameter Name="Memo" Type="String" />
           <asp:Parameter Name="FinishUserId" Type="Int32" />
           <asp:Parameter Name="CombineUserId" Type="Int32" />
       </InsertParameters>
                </asp:SqlDataSource>             
            </div>
</asp:Content>
